<?php 
 
namespace app\common\model;

use app\common\model\BaseModel;
use app\common\traits\ModelTrait;
use app\common\utils\JsonService;
/**
* This is the model class for table "{ptf_discount}".
*
* @property int $discount_id  
* @property string $discount_name 促销名称
* @property int $shop_id 店铺ID 
* @property int $goods_id 商品id 
* @property int $rate 折扣率 
* @property int $start_time 促销开始时间 
* @property int $end_time 促销结束时间 
* @property int $create_time 添加时间 
*/
class Discount extends BaseModel{

    protected $pk = 'discount_id';
    protected $name = 'discount';

    use ModelTrait;
    protected $autoWriteTimestamp = true;
    //protected $dateFormat = 'Y-m-d';
    //protected $createTime = 'create_time';
    //protected $updateTime = 'update_time';

    /**
    * {@inheritdoc}
    */
    public function attributeLabels()
    {
        return [
            'discount_id' => '',
            'discount_name' => '促销名称',
            'shop_id' => '店铺ID',
            'goods_id' => '商品id',
            'rate' => '折扣率',
            'start_time' => '促销开始时间',
            'end_time' => '促销结束时间',
            'create_time' => '添加时间',
        ];
    }

    public function getGoods(){
        return $this->hasOne('Goods','goods_id','goods_id')->field('goods_id,shop_id,goods_name,shop_price,original_img,goods_type,sales_sum,comment_count');
    }
}


?>